import { bg_image } from "./indoorConfig.js";
import {getUserInfo,getMerchantInfo} from "../api/home/index.js"
export default {
	data() {
		return {
			bg_image,
			show: false,
			nickname:'',
			headImgUrl:'',
			isShowMerchantOption: false // 是否显示商家充值选项
		}
	},
	onLoad() {
		this.fetchSomething()
	},
	onPullDownRefresh(){//页面下拉刷新
		this.fetchSomething()
		uni.stopPullDownRefresh();
	},
	methods: {
		fetchSomething(){
			// 监听车牌添加成功事件
			uni.$on('success', (plate) => {
				uni.showToast({
					title: plate,
					icon: 'none'
				})
				this.show = false
			})
			this.getUser()
		},
		addCar() {
			this.show = true
		},
		go(url) {
			uni.navigateTo({
				url
			})
		},
		callPhone() {
			uni.makePhoneCall({
				phoneNumber: '4006688393', //仅为示例，并非真实的电话号码
				success: function() {console.log("拨打电话成功！")},
				fail: function() {console.log("拨打电话失败！")}
			})
		},
		async getUser(){
			let res= await getUserInfo()
			let data = res.data || {}
			uni.setStorageSync('userInfo',data)
			this.nickname = data.nickname || ''
			this.headImgUrl = data.headImgUrl || ''
			let ress= await getMerchantInfo()
			let datas = ress.data || {}
			if(datas.id) this.isShowMerchantOption = true
		}
	}
}